package com.jiang.剑指Offer.栈或队列.NC269;

import java.util.Stack;

/**
 * @author Jiang
 * @version 1.0
 * @date 2024/12/24 21:48
 */
public class Solution {
    Stack<String> stack = new Stack<>();
    public String ReverseSentence(String str) {
        String[] s = str.split(" ");
        for (int i = s.length - 1; i >= 0; i--) {
            stack.add(s[i]);
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < stack.size(); i++) {
            sb.append(stack.get(i)).append(" ");
        }
        return sb.toString().trim();
    }
}
